Hard disk drives are divisible into multiple virtual hard disk drives via partitioning, in order to treat a single physical disk drive as if it were multiple disks. A partition editor software program (e.g. fdisk, GParted) can be used to create and delete these partitions.
Contents |
Creating more than one partition has the following advantages:
For example a 1 TB disk might have an access time of 12 ms at 200 IOPS (at a limited queue depth) with an average throughput of 100 MB/s. When it is partitioned to 100 GB (and the rest left unallocated) you might end up with an access time of 6 ms at 300 IOPS (with a bigger queue depth) with an average throughput of 200 MB/s..
This section describes the master boot record (MBR) partitioning scheme, as used in DOS, Microsoft Windows and Linux on PC compatible computer systems; for examples of partitioning schemes used in other operating systems, see GUID Partition Table, Slice (disk) or BSD disklabel.
The total data storage space of a PC hard disk is divided into at most four, and at least one, primary partitions. One of these can also be an extended partition. All these primary partitions are described by 16-byte entries that constitute the Partition Table which is located in the master boot record.
The partition type is identified by a 1-byte code found in its partition table entry. Some of these codes (such as 0x05 and 0x0F) may be used to indicate the presence of an extended partition, but most are used by operating systems that examine partition tables to decide if a partition contains a file system they can mount/access for reading or writing data.
Once a specific partition's type has been identified, additional information about its purpose and probable contents may be found (see: list of partition types). For example, some partition type codes are used to hide a partition's contents from various operating systems. However, if an OS or some partitioning tool has been programmed to also examine the boot sectors of any partition, then its file system may no longer remain hidden. (Note: There are no officially assigned partition types; thus, more than one kind of file system may lay claim to the same code value.) Additionally, partition types and boot indicators can be easily modified using applications such as MBRWizard if required.
A primary partition contains one file system. In MS-DOS and earlier versions of Microsoft Windows systems, the first partition (C:) must be a primary partition. Some operating systems are not limited in this way; however, this can depend on other factors, such as a PC's BIOS (see Boot sequence on standard PC for more information).
The partition type code for a primary partition can either correspond to a file system contained within (e.g. 0x07 means either an NTFS or an OS/2 HPFS file system) or indicate the partition has a special use (e.g. code 0x82 usually indicates a Linux swap partition). The FAT16 and FAT32 file systems have made use of quite a number of partition type codes over time due to the limits of various DOS and Windows OS versions. Though a Linux operating system may recognize a number of different file systems (ext2, ext3, ReiserFS, etc.), they have all consistently used the same partition type code: 0x83 (Linux native file system). This is the drive in which our boot sector has created.
An extended partition is a primary partition which contains secondary partition(s). A hard disk may contain only one extended partition; which can then be subdivided into logical partitions, each of which is (under DOS and Windows) assigned additional drive letters.
For example, under either DOS or Windows, a hard disk with one primary partition and one extended partition, the latter containing two logical drives, would typically be assigned the three drive letters: C: for the primary partition, and D: and E: for the two logical drives.
See extended boot record for information on the structure of an extended partition.
Hard disks can be compressed to create additional space. Under MS-DOS and early Microsoft Windows, programs such as Stacker (DR-DOS except 6), SuperStor (DR-DOS 6), DoubleSpace, or DriveSpace (Windows 95) were used. This compression was done by creating a very large file on the partition, then storing the disk's data in this file. At startup, device drivers opened this file and assigned it a separate letter. Frequently, to avoid confusion, the original partition and the compressed drive had their letters swapped, so that the compressed disk is C:, and the uncompressed area (often containing system files) is given a higher name. (SuperStor required a separate device driver to be loaded, DEVSWAP.COM).
Versions of Windows using the NT kernel, including the most recent versions, XP and Vista, contain intrinsic disk compression capability. The use of separate disk compression utilities has declined sharply.
The primary benefit of multiple partitions are to aid in reinstalling or restoring, the operating system (or all installed software) when the system has a problem that cannot otherwise be fixed.
With Microsoft Windows, DOS, and OS/2, a common partitioning scheme is to use one active primary partition for the file system containing the operating system (OS), utilities, applications, user data, and page/swap file. The designation for this file system is the C: drive. Most consumer computers are sold this way although they may have other partitions that are not visible as a normal file systems, such as for recovery (eg Dell recovery partition) or diagnostics (eg. Dell diagnostic partition).
Proponents of multiple partitions assert the benefits of keeping system files and data files separated because, in a system crash on a single-partition computer, the primary concern (for users, consumers, and technicians) is recovering original or irreplaceable user files. User data is thus stored on other partitions (D:, E:, F:, etc.), which also allows the data to be accessed by all installed Operating systems that can read the file system on the partition the data is stored.
On multi-partition single-disk setup where system and data are kept separate, OS crashes can be easily handled by the end user by simply repairing or even reinstalling the OS. In serious cases where the OS/system partition is entirely compromised, being able to erase the entire system partition, while retaining and not worrying about valuable data on another drive, is extremely time-saving and makes OS issues nearly trivial. This means in case of a system crash, virus infection, malware, spyware, program vs. system conflicts, lost system files, or other serious problem can be easily corrected on the system disk, and the data drive(s) can be tested later (after OS recovery) for infections.
When used in conjunction with third-party partition management programs, the use of multiple partitions allows computer users to quickly recover from viruses, rootkits, and trojan horses or an otherwise damaged, corrupt or compromised operating system. Examples of partition management programs are Acronis Disk Director and Norton Ghost. In some instances specialized recovery programs are supplied with computers manufactured by most major manufacturers,
Windows 2000, Windows XP, Windows Vista, and Windows 7 include an inbuilt 'Disk Management' program which allows for the creation, deletion and movement of partitions. Vista's Disk Manager is not compatible with Windows 2000 or XP.
On Unix-based and Unix-like operating systems such as Linux and Mac OS X, it is possible to use multiple partitions on a disk device. (Partitions are also known in the Solaris operating system and the BSD based operating systems as "slices".) Each partition can be used for a file system or as a swap partition.
Multiple partitions allow directories such as /tmp, /usr, /var, or home directory space to be allocated their own file system. Such a scheme has a number of potential advantages:
However, the disadvantage of subdividing the drive into fixed-size partitions is that a file system in one partition may become full, even though other file systems still have plenty of usable space.
A good partitioning scheme requires the user to predict how much space each partition will need, which may be a difficult task; especially for new users. Logical volume management (LVM), often used in servers, increases flexibility by allowing data in volumes to expand into separate physical disks (which can be added when needed). Another option is to resize existing partitions when necessary. LVM allows this easily by resizing (shrinking) a filesystem, reducing the size of the logical volume containing that filesystem, allocating that freed space to another logical volume, and expanding (resizing) this other filesystem.
Typical Linux desktop systems often use three partitions: one holding a file system mounted on "/" (the root directory), a smaller partition holding the "/boot" directory, and a swap partition. This is done to allow a wider choices of file systems and logical volume management schemes for the root directory; a boot manager like GRUB will only need to understand the file system type used for "/boot". Some others also use a separate /home parition to separate user data from system data, thus simplifying reinstallations or upgrades.
By default, Mac OS X systems also use a single partition for the entire filesystem, but use a swap file inside the file system (like Windows) rather than a swap partition.
Multi-boot systems are computers where the user can boot into more than one distinct operating system (OS). In such systems, the user is given a choice, at startup, of which OS they wish to use, as only one can run at a time on a single-processor computer. (However, computers with virtual operating systems installed or with multiple separated processors, may allow either running another OS within a window, such as Linux on Windows, or switching between OSes.).
Multi-boot systems are typically mixed-boot systems, with different OSes installed. A typical case is a machine with Windows (XP, Vista, Windows 7) as the default OS and any Linux distribution as a second OS. Another example is a multi-boot with Windows and Mac OS X—a configuration made possible by Apple's switch to the x86 processor architecture, and by Apple's own multi-boot utility (Boot Camp). Another common example of multi-boot is the installation of the same OS on more than one partition. This allows the testing of new software updates without compromising the existing installation.
Multi-boot systems generally have two fundamental issues which need to be understood and handled before any installation. In short, the disk must be partitioned with consideration for the proper installation and setup of each operating system, and the sharing of files across non-mutually intelligent systems.
The first issue can be complicated by several things, the major complications being the OS's ability to recognize the partition order, and partition (and even file system) issues arising from an incompatibility between partition setups. In general, machines with Windows installed should use Windows-based partition tools and not Linux ones. (Linux tools work, but Windows can be picky when dealing with a boot partition that was created under Linux or Mac).
The second issue deals with the boot manager and its installation, and the required configurations and settings a boot manager must have in order to boot each OS. Most Linux distributions provide a simple to install boot manager such as GNU GRUB or LILO, but these usually require overwriting the MBR as set up by Windows. Linux boot managers always recognize NTFS partitions and Windows OSes, but Windows variants generally do not do a good job of recognizing either Linux or Mac, and Windows notoriously does not give a choice to not overwrite the MBR with a Windows bootloader.
When a partition is deleted, in general, only its partition table entry is removed from a table; and although the data are no longer accessible, some still remain on the disk until being overwritten. Specialized recovery utilities, (such as TestDisk and gpart), can locate lost file systems and recreate a partition table which includes entries for these recovered file systems. However, some disk utilities may also overwrite a number of beginning sectors of a partition they delete. For example, if Windows Disk Management (Windows 2000/XP, etc.) is used to delete a partition, it will overwrite the first sector (relative sector 0) of the partition before removing it. It may be possible to restore a FAT32 or NTFS partition if a backup boot sector is available.